<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="审批活动">
<style>
    .form-horizontal .controls {
        line-height: 40px;
        height: 40px;
    }
    .button-primary {
        margin-left: 5px;
    }
</style>
<form id="searchForm" class="form-panel" action="${basepath}/manage/offline/loadData">
    <ul class="panel-content">
        <li>
            <div class="control-group span5">
                <div class="search-controls  controls">
                    <input type="text" name="name" id="title" value="" placeholder="搜索活动名称、联系人">
                </div>
            </div>
            <div class="form-actions span2">
                <button type="submit" class="button  button-primary">
                    搜索
                </button>
            </div>
        </li>
    </ul>
</form>
<div id="grid"></div>
<script>
    /*-------------------------------------------------------- 表格数据渲染start-----------------------------------*/
    var Grid = BUI.Grid,
            Store = BUI.Data.Store,
            columns = [
                {title: '序号', dataIndex: 'id', elCls: 'center', width: '10%'},
                {title: '活动名称', dataIndex: 'name', elCls: 'center', width: '15%'},
                {title: '机构名称', dataIndex: 'organizeName', elCls: 'center', width: '15%'},
                {title: '联系人', dataIndex: 'principal', elCls: 'center', width: '15%'},
                {title: '参与人数', dataIndex: 'limits', elCls: 'center', width: '15%'},
                {
                    title: '活动状态', dataIndex: 'status', elCls: 'center', width: '15%', renderer: function (data) {
                    if (data == "1") {
                        return '待审核';
                    }
                    if (data == "2") {
                        return '已通过';
                    }
                    if (data == "3") {
                        return '已通过';
                    }
                    if (data == "4") {
                        return '已通过';
                    }
                    if (data == "5") {
                        return '已关闭';
                    }
                    if (data == "6") {
                        return '不通过';
                    }
                }
                },
                {
                    title: '操作', elCls: 'center', width: '15%', dataIndex: 'id', renderer: function (value, data) {
                    if (data.status == "2" || data.status == "3" || data.status == "4" || data.status == "5" || data.status == "6") {
                        return '<a   href="${basepath}/manage/offline/toCheckDetails?id=' + value + '">查看</a>'
                    }
                    if (data.status == "1") {
                        return '<a   href="${basepath}/manage/offline/toCheckEdit?id=' + value + '">审批</a>'
                    }

                }
                }
            ]
            ;
    var store = new Store({
                url: 'loadData',
                autoLoad: true, //自动加载数据
                params: { //配置初始请求的参数
                    length: '10',
                    status: $("#status").val()
                },
                pageSize: 10,	// 配置分页数目
                root: 'list',
                totalProperty: 'total'
            }),
            grid = new Grid.Grid({
                render: '#grid',
                columns: columns,
                loadMask: true, //加载数据时显示屏蔽层
                store: store,
                plugins: [Grid.Plugins.CheckSelection], // 插件形式引入多选表格

                // 底部工具栏
                bbar: {
                    pagingBar: true
                }
            });
    grid.render();

    var form = new BUI.Form.HForm({
        srcNode: '#searchForm'
    }).render();

    form.on('beforesubmit', function (ev) {
        //序列化成对象
        var obj = form.serializeToObject();
        obj.start = 0; //返回第一页
        store.load(obj);
        return false;
    });
    /*---------------------------------------------------表格数据渲染 end-------------------------------------------*/
</script>

</@page.pageBase>